<?php
// 连接mongodb服务器
$mongoClient = new MongoClient('mongodb://127.0.0.1:27017');

// 得到mongodb对象
$mongodb = $mongoClient->test;

/*
// 得到mongoCollection对象
$mongoColl = $mongodb->selectCollection('news');

$news = array(
    'title'=>'第一条新闻',
    'content'=>'第一条新闻的内容'
);

$mongoColl->insert($news);
*/

/*$str = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
$str = str_shuffle($str);
$list = str_split($str);

var_export($list);*/


$mongoColl = $mongodb->selectCollection('cnt');
$query = array('_id'=>1);
$update = array('$inc'=>array('sn'=>1));
$tmp = $mongoColl->findAndModify($query,$update);

var_dump($tmp);


